// <copyright file="IWebSecurityService.cs" company="Clever Software">
// Copyright (c) 2013, 2014 All Right Reserved, http://www.cleversoftware.by
//
// This source is subject to the Microsoft Permissive License.
// Please see the License.txt file for more information.
// All other rights reserved.
//
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 
// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// </copyright>
// <author>Clever Software</author>
// <email>info@cleversoftware.by</email>
// <date>2014-02-04</date> 
// <summary>CleverCMS source code</summary>

namespace CleverCMS.Core.Services
{
    using System;
	
    public interface IWebSecurityService
	{
		bool ChangePassword(string userName, string currentPassword, string newPassword);
		bool ConfirmAccount(string accountConfirmationToken);
		string CreateAccount(string userName, string password, bool requireConfirmationToken = false);
		string CreateUserAndAccount(string userName, string password, object propertyValues = null, bool requireConfirmationToken = false);
		string GeneratePasswordResetToken(string userName, int tokenExpirationInMinutesFromNow = 0x5a0);
		DateTime GetCreateDate(string userName);
		DateTime GetLastPasswordFailureDate(string userName);
		DateTime GetPasswordChangedDate(string userName);
		int GetPasswordFailuresSinceLastSuccess(string userName);
		int GetUserId(string userName);
		int GetUserIdFromPasswordResetToken(string token);
		void InitializeDatabaseConnection(string connectionStringName, string userTableName, string userIdColumn, string userNameColumn, bool autoCreateTables);
		void InitializeDatabaseConnection(string connectionString, string providerName, string userTableName, string userIdColumn, string userNameColumn, bool autoCreateTables);
		bool IsAccountLockedOut(string userName, int allowedPasswordAttempts, int intervalInSeconds);
		bool IsAccountLockedOut(string userName, int allowedPasswordAttempts, TimeSpan interval);
		bool IsConfirmed(string userName);
		bool IsCurrentUser(string userName);
		bool Login(string userName, string password, bool persistCookie = false);
		void Logout();
		void RequireAuthenticatedUser();
		void RequireRoles(params string[] roles);
		void RequireUser(int userId);
		void RequireUser(string userName);
		bool ResetPassword(string passwordResetToken, string newPassword);
		bool UserExists(string userName);
		// Properties
		int CurrentUserId { get; }
		string CurrentUserName { get; }
		bool HasUserId { get; }
		bool IsAuthenticated { get; }

		int MinPasswordLength { get; }
	}
}